package author

import (
	models "HeadLineNews/proto_models/manage/author_model"
	"HeadLineNews/utils"
	"github.com/gin-gonic/gin"
)

type Ctx interface {
	ParseParmAddAuthor(c *gin.Context) (p *models.RequestAddAuthor, err error)
	ParseParmUpdateAuthor(c *gin.Context) (p *models.RequestUpdateAuthor, err error)
	ParseParamListAuthor(c *gin.Context) (p *models.RequestListAuthor, err error)
}

type ctx struct{}

func NewCtx() Ctx {
	return &ctx{}
}

// ParseParmAddAuthor 解析新增作者的参数
func (ctx *ctx) ParseParmAddAuthor(c *gin.Context) (p *models.RequestAddAuthor, err error) {
	p = new(models.RequestAddAuthor)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParmUpdateAuthor 解析更新作者的参数
func (ctx *ctx) ParseParmUpdateAuthor(c *gin.Context) (p *models.RequestUpdateAuthor, err error) {
	p = new(models.RequestUpdateAuthor)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListAuthor 解析展示作者的参数
func (ctx *ctx) ParseParamListAuthor(c *gin.Context) (p *models.RequestListAuthor, err error) {
	p = new(models.RequestListAuthor)
	err = utils.ShouldBindProtobuf(c, p)
	return
}
